export const schema = {
    type: "page",
    title: "创建项目",
    toolbar: [

        {
            type: "button",
            actionType: "submit",
            label: "提交",
            icon: "fa fa-check pull-left",
            className: 'pull-right',

            level: "primary",
            target: "projectcreateform",
            redirect: "/project",
            visibleOn: 'acl.can("project:verify") && acl.can("project:commit")'
        },

        {
            type: "button",
            actionType: "submit",
            label: "提交",
            icon: "fa fa-check pull-left",
            className: 'pull-right',

            level: "primary",
            target: "projectcreateform",
            redirect: "/project",
            confirmText: "确认提交？提交后将不能再修改！",
            visibleOn: '!acl.can("project:verify") && acl.can("project:commit")'
        },

        {
            type: "button",
            actionType: "submit",
            className: 'pull-right',
            label: "保存",
            icon: "fa fa-save pull-left",
            level: "info",
            target: "projectcreateform",
            api: "post:/api/project?op=save",
            redirect: "/project/edit/${id}"
        },

        {
            type: 'tpl',
            visibleOn: 'acl.can("notify:unverified")',
            className: 'pull-right text-danger m-t-sm',
            tpl: '你的帐号还没有通过审核，只能暂存，不能提交。'
        }
    ],
    body: {
        api: "post:/api/project",
        submitText: "",
        name: "projectcreateform",
        type: "form",
        title: "",
        mode: "horizontal",
        footer: {
            type: 'tpl',
            visibleOn: 'acl.can("notify:unverified")',
            className: 'text-danger padder-v',
            tpl: '你的帐号还没有通过审核，只能暂存，不能提交。'
        },
        actions: [
            {
                type: "button",
                actionType: "submit",
                label: "保存",
                icon: "fa fa-save pull-left",
                level: "info",
                api: "post:/api/project?op=save",
                redirect: "/project/edit/${id}"
            },

            {
                type: "button",
                actionType: "submit",
                label: "提交",
                icon: "fa fa-check pull-left",
                level: "primary",
                redirect: "/project",
                visibleOn: 'acl.can("project:verify") && acl.can("project:commit")'
            },

            {
                type: "button",
                actionType: "submit",
                label: "提交",
                icon: "fa fa-check pull-left",
                level: "primary",
                redirect: "/project",
                confirmText: "确认提交？提交后将不能再修改！",
                visibleOn: '!acl.can("project:verify") && acl.can("project:commit")'
            }
        ],
        fieldSet: [
            {
                title: "基本信息",
                controls: [
                    {
                        type: "select",
                        name: "org_id",
                        label: "所属机构",
                        source: "/api/org/sug?_=${_}",
                        required: true,
                        inline: true,
                        visibleOn: "!data.query.org_id && !acl.can('skip:select-org')"
                    },

                    {
                        type: "select",
                        name: "team_id",
                        label: "所属团队",
                        inline: true,
                        required: true,
                        visibleOn: "!acl.can('skip:select-team')",
                        autoComplete: "/api/team/sug?term=${term}&org_id=${org_id}",
                        cache: false,
                        clearable: true,
                    },
                    {
                        type: "image",
                        label: "海报",
                        maxSize: 10 * 1024 * 1024,
                        // accept: "image/png,image/jpeg",
                        desc: '请选择 jpg 或者 png 图片，单个文件请不要超过 10M，建议尺寸比例：（750 x 400）。',
                        // desc: '请选择 jpg 或者 png 图片，单个文件请不要超过 1M',
                        name: "list_photo"
                    },
                    {
                        label: "项目名称",
                        name: "name",
                        type: "text",
                        // minLength: 5,
                        maxLength: 32,
                        required: true
                    },

                    {
                        type: "radios",
                        name: "service_target",
                        label: "服务对象",
                        columnsCount: 4,
                        source: "/api/setting/service_target?_=${_}",
                        required: true
                    },

                    {
                        type: "region",
                        name: "region",
                        label: "区域",
                        ignoreAddress: true,
                        required: true
                    },

                    [{
                        type: "map",
                        name: "address",
                        label: "服务地点",
                        desc: '请在地图上确定活动地点',
                        required: true
                    }, {type: 'plain'}],

                    [
                        {
                            label: "项目开始日期",
                            type: "date",
                            name: "begin",
                            required: true,
                            maxDate: '${end}'
                        },

                        {
                            label: "到",
                            labelClassName: "w-xxs",
                            type: "date",
                            name: "end",
                            required: true,
                            minDate: '${begin}'
                        }
                    ],

                    [{
                        label: "招募截止日期",
                        type: "date",
                        name: "join_end",
                        minDate: 'today',
                        maxDate: '${end}',
                        required: true
                    }, {type: 'plain'}],

                    {
                        label: "计划招募人数",
                        name: "people_count",
                        type: "number",
                        width: 100,
                        required: true
                    },

                    {
                        label: "项目时长",
                        name: "reward_time",
                        type: "number",
                        width: 100,
                        required: true,
                        desc: "输入每次参与该活动可获得的志愿者服务时长",
                        placeholder: '小时'
                    },

                    {
                        type: "checkboxes",
                        name: "project_type",
                        label: "服务类型",
                        columnsCount: 4,
                        source: "/api/setting/project_type?_=${_}",
                        required: true
                    },

                    {
                        type: "checkboxes",
                        name: "volunteer_security",
                        label: "志愿者保障",
                        columnsCount: 4,
                        source: "/api/setting/volunteer_security?_=${_}"
                    },

                    {
                        type: "rich-text",
                        name: "content",
                        label: "项目概述",
                        required: true
                    },

                    {
                        type: "image",
                        name: "photo",
                        label: "详情页banner",
                        multiple: true,
                        maxSize: 10 * 1024 * 1024,
                        maxLength: 5,
                        // accept: "image/png,image/jpeg",
                        desc: '请选择 jpg 或者 png 图片，单个文件请不要超过 10M，最多可上传5张。建议尺寸比例：（750 x 440）。',
                    }
                ]
            },

            {
                title: "联系人信息",
                controls: [
                    {
                        type: "text",
                        label: "联系人姓名",
                        name: "contact_name",
                        required: true
                    },

                    {
                        type: "text",
                        label: "联系人电话",
                        placeholder: "固话或者手机号",
                        name: "contact_phone",
                        validations: 'isTelOrPhone',
                        className: "m-b-none",
                        required: true
                    },

                    {
                        type: "checkbox",
                        name: "contact_phone_public",
                        option: "是否公开？",
                        value: "1",
                        label: "",
                        trueValue: "1",
                        falseValue: "0"
                    },

                    // {
                    //     type: "text",
                    //     label: "办公电话",
                    //     name: "work_tel",
                    //     className: "m-b-none",
                    //     validations: 'isTel'
                    // },
                    //
                    // {
                    //     type: "checkbox",
                    //     name: "work_tel_public",
                    //     option: "是否公开？",
                    //     value: "1",
                    //     label: "",
                    //     trueValue: "1",
                    //     falseValue: "0"
                    // },
                    //
                    // {
                    //     type: "text",
                    //     label: "办公邮箱",
                    //     name: "work_email",
                    //     validations: 'isEmail'
                    // }
                ]
            },

            {
                title: "报名需要收集的志愿者其他信息",
                subTitle: "如需要报名的志愿者提供除注册填写的信息之外的信息，请在这里添加设置",
                className: 'm-t-lg',
                controls: [
                    {
                        type: 'combo',
                        name: 'custom_config',
                        multiple: true,
                        dragable: true,
                        // multiLine: true,
                        noOffset: true,
                        maxLength: 50,
                        controls: [
                            // {
                            //     name: 'key',
                            //     placeholder: '标识',
                            //     type: 'text'
                            // },
                            {
                                name: 'label',
                                placeholder: '标题',
                                type: 'text',
                                // required: true,
                                validations: 'isRequired',
                            },
                            {
                                type: 'select',
                                name: 'type',
                                placeholder: "类别",
                                // required: true,
                                validations: 'isRequired',

                                options: [
                                    {
                                        value: '1',
                                        label: '单项选择'
                                    },

                                    {
                                        value: '2',
                                        label: '多项选择'
                                    },

                                    {
                                        value: '3',
                                        label: '单行输入'
                                    },

                                    {
                                        value: '4',
                                        label: '多行输入'
                                    },

                                    {
                                        value: '5',
                                        label: '上传图片'
                                    },

                                    {
                                        value: '6',
                                        label: '日期控件'
                                    },

                                    {
                                        value: '7',
                                        label: '时间控件'
                                    }
                                ]
                            },

                            {
                                type: "text",
                                name: "options",
                                placeholder: "内容逗号分隔(如:选项A,选项B)",
                                visibleOn: "data.type == 1 || data.type == 2",
                                validations: 'isPro',

                                // desc: "请用英文标点\",\"分格",
                                // requiredOn: "data.type == 1 || data.type == 2",
                            },
                            {
                                type: 'select',
                                name: 'is_required',
                                placeholder: "是否必填",
                                // required: true,
                                validations: 'isRequired',

                                options: [
                                    {
                                        value: '1',
                                        label: '是'
                                    },

                                    {
                                        value: '0',
                                        label: '否'
                                    },
                                ],
                            }
                        ]
                    },
                ],
            },
            {
                title: "添加收款信息",
                subTitle: "如该活动需要收取报名费，请在这里添加设置",
                className: 'm-t-lg',
                controls: [
                    {
                        type: 'combo',
                        name: 'custom_payment_config',
                        multiple: true,
                        dragable: true,
                        // multiLine: true,
                        noOffset: true,
                        maxLength: 50,
                        controls: [
                            {
                                name: 'amount',
                                placeholder: '金额',
                                validations: 'isNumeric,isRequired',
                                // required: true,
                                type: 'text'
                            },
                            {
                                name: 'label',
                                placeholder: '商品名称',
                                // required: true,
                                validations: 'isRequired',
                                type: 'text'
                            },
                            // {
                            //     name: 'count',
                            //     placeholder: '数量',
                            //     validations: 'isNumeric',
                            //     required: true,
                            //     type: 'text'
                            // },
                            {
                                type: 'select',
                                name: 'is_required',
                                placeholder: "是否必填",
                                // required: true,
                                validations: 'isRequired',
                                options: [
                                    {
                                        value: '1',
                                        label: '是'
                                    },

                                    {
                                        value: '0',
                                        label: '否'
                                    },
                                ],
                            }
                        ],
                    }
                ],
            },
        ]
    }
};
